#include "gmock/gmock.h"
#include "StaticArray.h"
#include "GTree.h"
#include "GtreeNode.h"
using namespace LQLib;
using namespace testing;


TEST(GTree, creat) {
	GTree<int> tt;
	GTreeNode<int> tn;
}

TEST(GTree, findSomeOneInGTree) {
	GTree<char> t;
	GTreeNode<char>* node = nullptr;

	t.insert('A', nullptr);
	node = t.find('A');
	t.insert('B', node);
	t.insert('C', node);
	t.insert('D', node);

	node = t.find('B');
	t.insert('E', node);
	t.insert('F', node);

	node = t.find('E');
	t.insert('K', node);
	t.insert('L', node);


	node = t.find('C');
	t.insert('O', node);

	node = t.find('O');
	t.insert('N', node);


	node = t.find('D');
	t.insert('H', node);
	t.insert('I', node);
	t.insert('J', node);


	node = t.find('H');
	t.insert('M', node);

	
	std::string charactors{ "KLFNMIJ" };
	for (auto iter = charactors.begin(); iter != charactors.end(); ++iter)
	{
	}

	for (auto& c : charactors)
	{
		// check
		TreeNode<char>* fnode = t.find(c);

		while (fnode != nullptr) {
			std::cout << fnode->value << " ";
			fnode = fnode->parent;
		}

		std::cout << "\n";
	}

	// traversal
	std::cout << "using Cursor\n";
	for (t.begin(); !t.end(); t.next())
	{
		std::cout << t.current() << std::endl;
	}
	
	std::cout << "haha~" << std::endl;

	t.clear();

	std::cout << "end~" << std::endl;
	for (auto& c : charactors)
	{
		// check
		TreeNode<char>* fnode = t.find(c);

		while (fnode != nullptr) {
			std::cout << fnode->value << " ";
			fnode = fnode->parent;
		}

		std::cout << "\n";
	}
}